<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script src="./lodash.js"></script>
<script src="./d3.js"></script>
<script>

    function offset(type,date,set){
        const wrap = {
            "year":"timeYear",
            "month":"timeMonth",
            "day":"timeDay",
            "hour":"timeHour"
        }
        return _.flow([
            d3.timeParse(type),
            _.curry(d3[wrap[date]].offset)(_,set),
            d3.timeFormat(type)
        ]) 
    }
    const setOffset = offset('%Y-%m-%d %H:%M:%S',"year",-2);
    const getoffset = setOffset("2022-10-22 09:46:37");
    console.log(getoffset);
</script>